<template>
  <div class="reItem" @click="toPlatformDetail">
    <div class="reRow1 vux-1px-b">
      <img :src="item2.logo">
      <line1 len="0.4rem" style="margin:0 0.2667rem"></line1>
      <div class="titleBox">
        {{this.item2.name}}
        <div v-if="!item2.tags">
          <Tag :tag="item2.style" style="margin-left:.2667rem"></Tag>
          <Tag :tag="item2.is_new !== '2'?'':'新手标'" style="margin-left:.2rem"></Tag><!--增加 新手标 标签-->
        </div>
        <div v-else>
          <Tag :tag="val" style="margin-left:.2rem" v-for="val in item2.tags" :key="val.id"></Tag>
        </div>
      </div>
      <img src="../../../../static/assets/arrowr.jpg">
    </div>
    <div class="reRow2">
      <div class="col1">
        <div class="itemBox">
          <span id="yearRateBox">
            <div v-if="type=='productDetail'">
              <span class="yearRate">{{this.item2.yqnh}}</span>%
            </div>
            <div v-else>
              <span class="yearRate">{{this.item2.yqnh_min}}</span>%~<span class="yearRate">{{this.item2.yqnh_max}}</span>%
            </div>
          </span>
          <span>预期年化</span>
        </div>
        <div class="itemBox" :style="type!=='productDetail'?'margin-left:0.1rem':'margin-left:.4rem;margin-right:.6rem'" v-if="item2.zgfl != 0">
          <span id="reBackBox">
            <div v-if="isYuan">
              <span class="reBack">{{parseInt(this.isYuan2)}}</span>元
            </div>
            <div v-else>
              <span class="reBack">{{this.isYuan2}}</span>%
            </div>
          </span>
          <span>最高返利</span>
        </div>
      </div>
      <line1 style="margin:0 0.2rem 0 .2rem"></line1>
      <div class="qixianqitou">
        <div>
          期限<span class="txt">{{this.item2.qixian}}</span><span v-text="item2.qixianlx=='month'?'个月':'天'" style="color:#000"></span>
        </div>
        <div>
          起投<span class="txt">{{parseInt(this.item2.qtje)|addYuan}}</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Line1 from './Line'
import Tag from './Tag'
import {setStore} from '../../../config/mUtils.js'
import {cpDetail} from '../../../service/getData.js'

export default {
  components:{
    Line1,
    Tag,
  },
  props:['item','type'],
  data(){
    return {
      cssOB:{
        margin:'0 0.4rem 0 1rem',
      },
      isYuan:false,
      item2:this.item
    }
  },
  computed:{
    isYuan2(){
      this.isYuan = this.item2.type == 1
      return this.isYuan?this.item2.zgfl||' '.substring(0,this.item2.zgfl||' '.length-1):this.item2.zgfl;
    },
  },
  methods:{
    toPlatformDetail(){
      switch(this.type){
        case 'platformDetail':
          // this.$router.push({name:'PlatformDetail',params:{id:this.item2.id}})
          this.$router.push('/platformDetail?cid='+this.item2.id)
          // setStore('pt',this.item2.id)
        break;
        case 'productDetail':
          if(this.$route.path == '/productDetail'){//产品详情里的产品跳转
            cpDetail(this.item2.id)
            .then(res=>{
              // console.log(res)
              if(res.status == 1){
                this.item2 = null;
                this.item2 = res.info
                // setStore('cp',res.info.id)
                this.$router.replace('/productDetail?pid='+res.info.id)
                location.reload()
              }
            })
          }else{
            // this.$router.push({name:'ProductDetail',params:{id:this.item2.id}})
            this.$router.push('/productDetail?pid='+this.item2.id)
            // setStore('cp',this.item2.id)
          }
        break;
      }
    }
  },
}
</script>
<style lang="less" scoped>
  .reItem{
    box-sizing: border-box;
    width: 9.2rem;
    height: 3.226667rem;
    box-shadow:2px 2px 10px #aaa;
    padding: 0 .4rem;
    // background-color: burlywood;
    .reRow1{
      height: .986667rem;
      display: flex;
      flex-direction: row;
      align-items: center;
      // line-height: .986667rem;
      font-size: 0.3733rem;
      .titleBox{
        display: flex;
        flex-direction: row;
        width:77%;
      }
      img:first-child{
        width: 1.1333rem;
        height: 0.4133rem;
      }
      img:last-child{
        width: 0.16rem;
        height: 0.32rem;
        display: inline-block;
        float: right;
      }
    }
    .reRow2{
      height: 2.1rem;
      // background-color: cornflowerblue;
      display: flex;
      flex-direction: row;
      align-items: center;
      font-size: 0.32rem;
      color: #c6c6c6;
      .col1{
        display: flex;
        flex-direction: row;
        width:64%;
        // justify-content: center;
      }
      .itemBox{
        display: flex;
        flex-direction: column;
      }
      #yearRateBox{
        color:#dd3930;
        .yearRate{
          font-size: 0.56rem;
          // margin-right:.1rem;
          font-weight: bold
        }
      }
      #reBackBox{
        color:#000;
        .reBack{
          font-size: 0.56rem;
          font-weight: bold;
          margin-right: .1rem;
        }
      }
      .qixianqitou{
        font-size: 0.3467rem;
      }
      .txt{
        margin-left: 0.2667rem;
        color:#000;
        width:.2rem
      }
    }
  }
</style>
